<script setup>
import { ref, reactive, onMounted, watch, watchEffect } from 'vue'
import { useRouter } from 'vue-router'
import plat from '@platform'

const router = useRouter()
const message = ref('Hello World!')
const data = reactive({ name: 1 })
const env = import.meta.env

onMounted(() => {
  console.log(`the component is now mounted.`)
  console.log(env)
  console.log(plat)
})

const jump = () => {
  data.name = 222
  // router.push('about')
}

watchEffect(async () => {
  //  初始化会调用
  console.log(`进入watchEffect: ${data.name}`)
})

watch(data, (newValue) => {
  console.log(`进入watch: ${newValue}`)
})
</script>

<template>
  <main>
    <div class="message" @click="jump">{{ message }}</div>
    {{ data.name }}
    <div class="wrap">
      <div class="txt">2222</div>
    </div>
  </main>
</template>

<style lang="scss" scoped>
.message {
  font-size: 20px;
}
.wrap {
  .txt {
    color: $color666;
  }
}
</style>
